home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / hity wydania / GIMP 2.6.8 / gimp-2.6.8-i686-setup.exe / {app} / share / gimp / 2.0 / scripts / unsharp-mask.scm < prev    next >
Text File  |  2009-12-15  |  3KB  |  85 lines

  1. ;;; unsharp-mask.scm
  2. ;;; Time-stamp: <1998/11/17 13:18:39 narazaki@gimp.org>
  3. ;;; Author: Narazaki Shuji <narazaki@gimp.org>
  4. ;;; Version 0.8
  5.  
  6. (define (script-fu-unsharp-mask img drw mask-size mask-opacity)
  7.   (let* (
  8.         (drawable-width (car (gimp-drawable-width drw)))
  9.         (drawable-height (car (gimp-drawable-height drw)))
  10.         (new-image (car (gimp-image-new drawable-width drawable-height RGB)))
  11.         (original-layer (car (gimp-layer-new new-image
  12.                                              drawable-width drawable-height
  13.                                              RGB-IMAGE "Original"
  14.                                              100 NORMAL-MODE)))
  15.         (original-layer-for-darker 0)
  16.         (original-layer-for-lighter 0)
  17.         (blured-layer-for-darker 0)
  18.         (blured-layer-for-lighter 0)
  19.         (darker-layer 0)
  20.         (lighter-layer 0)
  21.         )
  22.  
  23.     (gimp-selection-all img)
  24.     (gimp-edit-copy drw)
  25.  
  26.     (gimp-image-undo-disable new-image)
  27.  
  28.     (gimp-image-add-layer new-image original-layer 0)
  29.     (gimp-floating-sel-anchor
  30.       (car (gimp-edit-paste original-layer FALSE)))
  31.  
  32.     (set! original-layer-for-darker (car (gimp-layer-copy original-layer TRUE)))
  33.     (set! original-layer-for-lighter (car (gimp-layer-copy original-layer TRUE)))
  34.     (set! blured-layer-for-darker (car (gimp-layer-copy original-layer TRUE)))
  35.     (gimp-drawable-set-visible original-layer FALSE)
  36.     (gimp-display-new new-image)
  37.  
  38.     ;; make darker mask
  39.     (gimp-image-add-layer new-image blured-layer-for-darker -1)
  40.     (plug-in-gauss-iir RUN-NONINTERACTIVE
  41.                new-image blured-layer-for-darker mask-size TRUE TRUE)
  42.     (set! blured-layer-for-lighter
  43.           (car (gimp-layer-copy blured-layer-for-darker TRUE)))
  44.     (gimp-image-add-layer new-image original-layer-for-darker -1)
  45.     (gimp-layer-set-mode original-layer-for-darker SUBTRACT-MODE)
  46.     (set! darker-layer
  47.           (car (gimp-image-merge-visible-layers new-image CLIP-TO-IMAGE)))
  48.     (gimp-drawable-set-name darker-layer "darker mask")
  49.     (gimp-drawable-set-visible darker-layer FALSE)
  50.  
  51.     ;; make lighter mask
  52.     (gimp-image-add-layer new-image original-layer-for-lighter -1)
  53.     (gimp-image-add-layer new-image blured-layer-for-lighter -1)
  54.     (gimp-layer-set-mode blured-layer-for-lighter SUBTRACT-MODE)
  55.     (set! lighter-layer
  56.           (car (gimp-image-merge-visible-layers new-image CLIP-TO-IMAGE)))
  57.     (gimp-drawable-set-name lighter-layer "lighter mask")
  58.  
  59.     ;; combine them
  60.     (gimp-drawable-set-visible original-layer TRUE)
  61.     (gimp-layer-set-mode darker-layer SUBTRACT-MODE)
  62.     (gimp-layer-set-opacity darker-layer mask-opacity)
  63.     (gimp-drawable-set-visible darker-layer TRUE)
  64.     (gimp-layer-set-mode lighter-layer ADDITION-MODE)
  65.     (gimp-layer-set-opacity lighter-layer mask-opacity)
  66.     (gimp-drawable-set-visible lighter-layer TRUE)
  67.  
  68.     (gimp-image-undo-enable new-image)
  69.     (gimp-displays-flush)
  70.   )
  71. )
  72.  
  73. (script-fu-register "script-fu-unsharp-mask"
  74.   "Unsharp Mask..."
  75.   "Make a new image from the current layer by applying the unsharp mask method"
  76.   "Shuji Narazaki <narazaki@gimp.org>"
  77.   "Shuji Narazaki"
  78.   "1997,1998"
  79.   ""
  80.   SF-IMAGE      "Image"             0
  81.   SF-DRAWABLE   "Drawable to apply" 0
  82.   SF-ADJUSTMENT _"Mask size"        '(5 1 100 1 1 0 1)
  83.   SF-ADJUSTMENT _"Mask opacity"     '(50 0 100 1 1 0 1)
  84. )
  85.